﻿@{
	//var index = 1;
}
@{
	var a = ViewData["list"] as List<SSD>;
}
@using HrEFCore.Models
@using HrEFCore
@model SS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-trasitional.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<script src="~/aa/vue/dist/vue.js"></script>
	<script src="~/aa/element-ui/lib/index.js"></script>
	<link href="~/aa/element-ui/lib/theme-chalk/index.css" rel="stylesheet" />
	<script src="~/aa/axios/dist/axios.js"></script>
	<script src="~/aa/jquery-3.4.1.js"></script>
	<script src="~/aa/jquery.validate.js"></script>
	<script src="~/aa/jquery.validate.unobtrusive.js"></script>
	<link rel="stylesheet" href="../../css/table.css" type="text/css" />
	<script type="text/javascript" src="../../javascript/comm/comm.js"></script>
	<script type="text/javascript" src="../../javascript/jquery-1.7.2.js"></script>
	<title>无标题文档</title>
	<style type="text/css">
		body {
			background: rgb(253,244,227);
		}

		.TD_STYLE1 {
			background: #E6DDCE;
			/* color:white; */
		}

		.TD_STYLE2 {
			background: rgb(253,244,227);
		}

		.INPUT_STYLE2 {
			background: rgb(253,244,227);
		}
	</style>
</head>
<body>

	<form method="post" action="/SS/BGUpdate2">
		<table width="100%">
			<tr>
				<td>
					<font color="black">
						您正在做的业务是：人力资源--薪酬标准管理--薪酬标准登记变更
					</font>
				</td>
			</tr>
			<tr>
				<td align="right">
					<input type="submit" value="重新提交" class="BUTTON_STYLE1">
					<input type="button" value="返回" class="BUTTON_STYLE1"
						   onclick="history.back();">
				</td>
			</tr>
		</table>
		<table id="stable" width="100%" border="1" cellpadding=0 cellspacing=1
			   bordercolorlight=#848284 bordercolordark=#eeeeee
			   class="TABLE_STYLE1 table-bordered">
			<tr>
				<td width="74" class="TD_STYLE1" hidden>
					@* 薪酬标准编号 *@
					@Html.LabelFor(e=>e.SsdId)
				</td>
				<td width="168" class="TD_STYLE2" hidden>
					@* @Html.TextBoxFor(e=>e.SsdId, new { @class = "form-control" ,@readonly="readonly"}) *@
					<input type="text" name="SsdId" id="SsdId" value="@Model.SsdId" readonly="readonly" class="form-control">
				</td>
				<td width="74" class="TD_STYLE1">
					@* 薪酬标准编号 *@
					@Html.LabelFor(e=>e.StandardId)
				</td>
				<td width="168" class="TD_STYLE2">
					@* @Html.TextBoxFor(e=>e.StandardId, new { @class = "form-control" ,@readonly="readonly"}) *@
					<input type="text" name="StandardId" id="StandardId" readonly="readonly" value="@Model.StandardId" class="form-control">
				</td>
				<td width="83" class="TD_STYLE1">
					@Html.LabelFor(e=>e.StandardName)
					@* 薪酬标准名称 *@
				</td>
				<td width="171" class="TD_STYLE2">
					@Html.TextBoxFor(e=>e.StandardName,new {@class="form-control"})
					@Html.ValidationMessageFor(e=>e.StandardName)
					@* <input type="text" name="standard.standardName" id="standardName" class="INPUT_STYLE2"> *@
				</td>
				<td width="170" class="TD_STYLE1">
					@Html.LabelFor(e=>e.SalarySum)
					@* 薪酬总额 *@
				</td>
				<td width="138" class="TD_STYLE2">
					@* @Html.TextBoxFor(e=>e.SalarySum,new{@class="form-control"})
					@Html.ValidationMessageFor(e=>e.SalarySum) *@
					<input type="text" name="SalarySum" id="SalarySum" value="@Model.SalarySum" readonly class="form-control" />
				</td>

			</tr>
			<tr>
				<td class="TD_STYLE1">
					@Html.LabelFor(e=>e.Designer)
					@* 制定人 *@
				</td>
				<td class="TD_STYLE2">
					@Html.TextBoxFor(e=>e.Designer,new{@class="form-control"})
					@Html.ValidationMessageFor(e=>e.Designer)
					@* <input type="text" id="designer" name="standard.designer" class="INPUT_STYLE2"> *@
				</td>
				<td class="TD_STYLE1">
					@Html.LabelFor(e=>e.Changer)
					@* 复核人 *@
				</td>
				<td class="TD_STYLE2">
					@* @Html.TextBoxFor(e=>e.Register,new {@class="form-control",@readonly="readonly"})
					@Html.ValidationMessageFor(e=>e.Register) *@
					<input type="text" name="Changer" value="@ViewBag.uname" readonly="readonly" class="form-control">
				</td>
				<td class="TD_STYLE1">
					@Html.LabelFor(e=>e.ChangeTime)
					@* 复核时间 *@
				</td>
				<td class="TD_STYLE2">
					@* @Html.TextBoxFor(e => e.RegistTime, new { @class = "form-control", type = "date" ,@readonly="readonly"})
					@Html.ValidationMessageFor(e=>e.RegistTime) *@
					<input type="text" id="ChangeTime" name="ChangeTime" readonly="readonly" class="form-control">
				</td>

			</tr>
			<tr>
				<td class="TD_STYLE1">
					@Html.LabelFor(e=>e.Remark)
					@* 备注 *@
				</td>
				<td colspan="7" class="TD_STYLE2">
					@Html.TextAreaFor(e=>e.Remark,new { @class = "my-textarea", style = "width: 900px; height: 100px;" })
					@* <textarea name="standard.remark" rows="4" class="TEXTAREA_STYLE1"></textarea> *@
				</td>
			</tr>


			</tbody>
		</table>
		@* <tbody>
		<input type="checkbox" id="checkAll" value="全选" />全选
		<input type="button" value="薪酬组成" onclick="getSelectedValues()" />
		@foreach (CPC cpc in @a)
		{
		<input type="checkbox" id="ItemName" name="ItemName" value="@cpc.AttributeName">

		@cpc.AttributeName
		}
		</tbody> *@
		<table id="stable" width="100%" border="1" cellpadding=0 cellspacing=1
			   bordercolorlight=#848284 bordercolordark=#eeeeee
			   class="TABLE_STYLE1 table-bordered">
			<tr class="TD_STYLE1">
				<td align="center">
					序号
				</td>
				<td colspan="3">
					薪酬项目名称
				</td>
				<td>
					金额
				</td>
				<td colspan="3">
					&nbsp;
				</td>
			</tr>
			<tbody id="tbody">
				@foreach (SSD ssd in @a)
				{
					<tr class="TD_STYLE1">
						<td align="center" hidden>@ssd.SdtId<input type="hidden" id="SdtId" name="SdtId" value="@ssd.SdtId"></td>
						<td align="center" hidden>@ssd.StandardId<input type="hidden" id="StandardId" name="StandardId" value="@ssd.StandardId"></td>
						<td align="center">@ssd.SdtId<input type="hidden" id="ItemId" name="ItemId" value="@ssd.ItemId"></td>
						<td colspan="3">@ssd.ItemName<input type="hidden" id="ItemName" name="ItemName" value="@ssd.ItemName"></td>
						<td colspan="3">
							<input type="text" id="Salary" value="@ssd.Salary" name="Salary" onkeyup="countMoney('Salary')"
								   class="INPUT_STYLE2">
						</td>
					</tr>
				}
			</tbody>
		</table>

		<p>
			&nbsp;
		</p>
	</form>

	<script type="text/javascript">
		function check() {

			var designer = document.getElementById("designer");
			var standardName = document.getElementById("standardName");
			if (designer.value.length <= 0) {
				alert("制定人不可为空!!!");
				return;
			}
			if (standardName.value.length <= 0) {
				alert("薪酬标准名称不可为空!!!");
				return;
			}
			document.forms[0].submit();
		}
		function countMoney(obj) {
			document.getElementById("SalarySum").value = parseFloat(0);

			let sum = parseFloat(0);


			var test = document.getElementsByName("Salary");
			if (document.getElementById("SalarySum").value == "0.00") {
				document.getElementById("SalarySum").value = parseFloat(0);
			}
			for (let i = 0; i < test.length; i++) {
				if (test[i].value == "0.00") {
					test[i] = parseFloat(0);
				} else {
					test[i] = parseFloat(test[i].value);
				}
				console.log("i:" + test[i].value);
				sum = parseFloat(sum) + parseFloat(test[i].value);

			}
			console.log("薪酬总额:" + document.getElementById("SalarySum").value);
			console.log("sum:" + sum);
			document.getElementById("SalarySum").value = sum;

		}

		function time() {
			var tdate = document.getElementById("ChangeTime");
			var d = new Date();
			var y = d.getFullYear();
			var moth = d.getMonth() + 1;
			var date = d.getDate();
			var h = d.getHours();
			var m = d.getMinutes();
			var s = d.getSeconds();
			var hh = 20 - 1 - h;
			var mm = 60 - 1 - m;
			var ss = 60 - s;
			if (hh > 0) {
				mm = mm + 60 * hh;
			}
			if (moth < 10) {
				moth = "0" + moth;
			}
			if (date < 10) {
				date = "0" + date;
			}
			if (h < 10) {
				h = "0" + h;
			}
			if (m < 10) {
				m = "0" + m;
			}
			if (s < 10) {
				s = "0" + s;
			}
			if (mm < 10) {
				mm = "0" + mm;
			}
			if (ss < 10) {
				ss = "0" + ss;
			}

			tdate.value = y + "-" + moth + "-" + date + " " + h + ":" + m + ":" + s;

		}
		window.onload = time;
		var out = window.setInterval(time, 1000);
	</script>
	<script>
		//获取全选
		document.getElementById("checkAll").addEventListener("change", function () {
			var itemNames = document.getElementsByName("ItemName");

			for (var i = 0; i < itemNames.length; i++) {
				itemNames[i].checked = this.checked;
			}
		});
		function getSelectedValues() {
			var selectedItems = [];
			var itemNames = document.getElementsByName("ItemName");
			for (var i = 0; i < itemNames.length; i++) {
				if (itemNames[i].checked) {
					selectedItems.push(itemNames[i].value);
				}
			}

			console.log(selectedItems); // 在控制台打印选中的值
			var tbody = document.getElementById("tbody");
			tbody.innerHTML = "";
			var index = 1;
			for (var j = 0; j < selectedItems.length; j++) {
				//(function (index) {
				console.log(selectedItems[j]);
				console.log(selectedItems);

				// 创建表格行
				var newRow = document.createElement("tr");
				//创建序号
				var itemId = document.createElement("td");
				itemId.name = "ItemId";
				itemId.innerHTML = j + 1;
				newRow.appendChild(itemId);
				//创建薪酬名称
				var itemName = document.createElement("td");
				itemName.setAttribute("colspan", "3");
				itemName.innerHTML = selectedItems[j];
				newRow.appendChild(itemName);

				//创建金额输入框
				var td2 = document.createElement("td");
				var input = document.createElement("input");

				input.type = "text";
				input.value = "0.00";
				input.name = "Salary";
				input.setAttribute("index", j);
				input.onblur = function () {
					countMoney(input);
				}
				td2.appendChild(input);
				newRow.appendChild(td2);
				// 将新行添加到表格中
				tbody.appendChild(newRow);
				countMoney(input);

			}
		}


	</script>
</body>
</html>